﻿
<?php 
@session_start();
if (!isset($_SESSION["taikhoan"]))
	{
		header("Location: cnk-dangnhap.php");
	}
include "connect.php"; 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>In kết quả bộ môn</title>
<style type="text/css">

a	{
		color: #006600;
		text-decoration: none;
	}

a:hover { COLOR:#FF0000}

.style2 {
	font-size: 18px;
	font-weight: bold;
	color: #FFFFFF;
}
.style3 {font-size: 14px; font-weight: bold; color: #FFFFFF; }
.style4 {
	color: #000099;
	font-weight: bold;
	font-size:20px;
}
.style5 {	color: #FFFFFF;
	font-weight: bold;
	font-size: 30px;
}
.cham { border-bottom-color:#666666;
		border-bottom-style:dotted;
		border-bottom-width:thin;	}
.bg {	border-right-color:#0066FF;
		border-bottom-color:#0066FF;
	}

.bg1 {	border-bottom-color:#0066FF;}

.bg2 {	border-top-color:#0066FF;}

.bg3 {	border-left-color:#0066FF;}

.bg4 {	border-right-color:#0066FF;}
.mo	{	color:#0000FF;	}
.style6 {
	
	color: #000099;
}
.style7{
	font-size: 20px;
	font-weight: bold;
}
.style8 {
	font-size: 20px;
	color: #000099;
}
</style>
<script language="javascript">
	function openUrl(a)
	{
		var win = window.open(a,'Buy ticket',
			'width=' + 1400 + ', height=' + 900 + ', ' +
			'left=' + 0 + ', top=' + 0 + ', ' +
			'location=no, menubar=no, ' +
			'status=no, toolbar=no, scrollbars=yes, resizable=no');
	}
</script>
</head>

<body>
<?php
      if($_GET["act"] == "in")
	  {
	  	$cnk = $_GET["cnk"];
	  }
	  else
	  {
	  	$cnk=$_SESSION['cnk'];
	  }
      //$cnk=$_SESSION['cnk'];
	  $hknk=$_REQUEST["hk"];
	  $tam1=mysql_query("select * from `hocki nienkhoa` where ma_hknk='$hknk' ");
	  $t1=mysql_fetch_row($tam1);
	  $hk=$t1[1];$nk=$t1[2];
	  $sql=mysql_query("select * from khoa where username='$cnk'");
	  $r=mysql_fetch_row($sql);
	  $makhoa=$r[0];
	  $tenkhoa=$r[1];
	  
		
?>
<!-- đầu trang --> 	
<?php
		            $kq=mysql_query("select extract(day from curdate()),extract(month from curdate()),extract(year from curdate()) "); 
					while ($r=mysql_fetch_row($kq))
					{
						$ngay=$r[0];
						$thang=$r[1];
						$nam=$r[2];
					}
		  ?>  
<?php // convert image to dataURL
$img_source = "image/logo.gif"; // image path/name
$img_binary = fread(fopen($img_source, "r"), filesize($img_source));
$img_string = "data:image/gif;base64,".base64_encode($img_binary);
?>

	<div align="right">
	<a href="#" onclick="openUrl('exportPDF.php<?php echo "?type=cnkinbomontc&cnk=".$cnk."&hk=".$_REQUEST["hk"]."&act=in"; ?>');"/>Mẫu In  <?php echo $ngay; ?>/<?php echo $thang; ?>/<?php echo $nam; ?></a></div>
	<tr> <td width="900">
   	  <table width="100%" border="0" >
          
          <tr bordercolor="#FFFFFF">
		     <td  rowspan="2" width="100"><img src="<?php echo $img_string; ?>" height="70" width="100" /></td>
            <td colspan="2"><div align="left" style="font-size:18px;" class="style6">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TRƯỜNG ĐẠI HỌC CẦN THƠ</div></td>
            <td colspan="3"><div align="center" style="font-size:18px; font-weight:bold;" class="style6">CỘNG HÒA XÃ HỘI CHỦ NGHĨA VIỆT NAM</div></td>
          </tr>
          
          <tr bordercolor="#FFFFFF">
            <td colspan="2"><div align="left" style="font-size:18px; font-weight:bold;" class="style6">Khoa <?php echo $tenkhoa; ?> </div></td>
            <td colspan="3"><div align="center" style="font-size:18px; font-weight:bold" class="style6" >Độc lập - Tự do - Hạnh phúc </div></td>
          </tr>
          
           <tr bordercolor="#FFFFFF">
            <td width="100" >&nbsp;</td>
			<td width="294" >&nbsp;</td>
			<td width="131" >&nbsp;</td>
            <td width="215">&nbsp;</td>
            <td width="108" class="bg2">&nbsp;</td>
            <td width="218">&nbsp;</td>
          </tr>
                    

          <tr bordercolor="#FFFFFF">
            <td height="40" colspan="6"  style="font-size:30px; font-weight:bold" class="style6" align="center" valign="bottom">
			     KẾT QUẢ ĐÁNH GIÁ HỌC PHẦN
            </td>
          </tr>
		  
		  <tr bordercolor="#FFFFFF">
            <td height="50" colspan="6"  style="font-size:20px; font-weight:bold" class="style6" align="center" valign="top">
			     Học Kì <?php echo $hk; ?> (<?php echo $nk; ?>)
            </td>
          </tr>
          
        
		 <tr valign="top" bordercolor="#FFFFFF">
            <td height="20" colspan="6" style="font-size:22px; font-weight:bold; color:#000099;">* Kết Quả Đánh Giá: </td>
            
        </tr>
         <tr valign="top" bordercolor="#FFFFFF">
            <td height="30"  > </td>
            <td colspan="5" ></td>
        </tr>
        </table>
    </td> 
	</tr>
	
	<!--than trang -->
	<tr><td>	
	<table width="1100" align="center" cellspacing="0" border="0"  cellpadding="0">
       		
      		
			<tr><td height="30">&nbsp;</td></tr>
			<?php
			      $str=mysql_query("select * from `bo mon` where ma_khoa='$makhoa'");
				  while ($str1=mysql_fetch_row($str))
				  {
				      $mabm=$str1[0];
					  $tenbm=$str1[1];
			?>
			<tr bordercolor="#FFFFFF"> 
           		<td align="left" height="40" class="bg1" valign="middle" style="font-size:24px; font-weight:bold; color:#000099">
                	
							* Bộ Môn: <?php  echo $tenbm; ?>
			   </td>
          	</tr>
			<tr><td height="30">&nbsp;</td></tr>
			<tr>
			    <td>
				       <table width="1100" align="center" cellspacing="0" border="1" bordercolor="#0066FF" cellpadding="0">
											
															
											<tr align="center"  bgcolor="#CCCCCC">
												<td  height="20"  rowspan="2" ><span class="style7">Mã Học Phần</span>				
												</td>
												<td  height="20"  rowspan="2" ><span class="style7">Tên Học Phần</span>				
												</td>
												<td   colspan="2"><span class="style7">Chưa Hài Lòng</span>			   
												</td>
												<td   colspan="2">
														  <span class="style7">Hài Lòng</span>				
												</td>
												<td   colspan="2">
														  <span class="style7">Rất Hài Lòng</span>				
												</td>
												<td   colspan="2">
														  <span class="style7">Xuất Sắc</span>				
												</td>
												
												
												
											</tr>
											<tr bgcolor="#CCCCCC">
											     
												 <td align="center" class="style7">
												       Số lượng
												 </td>
												 <td align="center" class="style7">
												       Tỉ lệ(%)
												 </td>
												 
												 <td align="center" class="style7">
												       Số lượng
												 </td>
												 <td align="center" class="style7">
												       Tỉ lệ(%)
												 </td>
												 
												 <td align="center" class="style7">
												       Số lượng
												 </td>
												 <td align="center" class="style7">
												       Tỉ lệ(%)
												 </td>
												 
												 <td align="center" class="style7">
												       Số lượng
												 </td>
												 <td align="center" class="style7">
												       Tỉ lệ(%)
												 </td>
												 
												 
											</tr>
								 <?php
		                $khl=array();
						$hl=array();
						$rhl=array();
						$xs=array();
		           
					
					   
													   $q=mysql_query("select  distinct(c.ma_hp),b.ten_hp from  `hoc phan` b, `lop hoc phan` c,`giang vien` d, `bo mon` e where  c.ma_hknk = '$hknk' and b.ma_hp=c.ma_hp and c.ma_gv=d.ma_gv and d.ma_bm=e.ma_bm and e.ma_khoa='$makhoa' and e.ma_bm='$mabm'  ");
													   while( $q1=mysql_fetch_row($q))
													   {
													            			
																$mahp=$q1[0];
									                            $tenhp=$q1[1];
																$demsv=0;
															     $truyvan=mysql_query("select * from `danh gia` a,`lop hoc phan` b where a.ma_hknk='$hknk' and a.ma_hp='$mahp' and ma_gv in (select ma_gv from `giang vien` where ma_bm='$mabm') and a.ma_hp=b.ma_hp and a.ma_hknk=b.ma_hknk and a.stt_nhom=b.stt_nhom  group by a.ma_sv,a.ma_hknk,a.stt_nhom,a.ma_hp");
																   while ($tv=mysql_fetch_row($truyvan))
																   {
																		  $demsv++;
																   }
																$sql1=mysql_query("select `muc danh gia`,count(*) from `danh gia` a,`lop hoc phan` b where  a.ma_hknk='$hknk' and `muc danh gia`='1' and a.ma_hp=b.ma_hp and a.ma_hknk=b.ma_hknk and a.stt_nhom=b.stt_nhom and a.ma_hp='$mahp' and ma_gv in (select ma_gv from `giang vien` where ma_bm='$mabm')  group by `muc danh gia`");
															    $sql2=mysql_query("select `muc danh gia`,count(*) from `danh gia` a,`lop hoc phan` b where a.ma_hknk='$hknk' and `muc danh gia`='2' and a.ma_hp=b.ma_hp and a.ma_hknk=b.ma_hknk and a.stt_nhom=b.stt_nhom and a.ma_hp='$mahp' and ma_gv in (select ma_gv from `giang vien` where ma_bm='$mabm') group by `muc danh gia`");
																$sql3=mysql_query("select `muc danh gia`,count(*) from `danh gia` a,`lop hoc phan` b where a.ma_hknk='$hknk'  and `muc danh gia`='3' and a.ma_hp=b.ma_hp and a.ma_hknk=b.ma_hknk and a.stt_nhom=b.stt_nhom and a.ma_hp='$mahp' and ma_gv in (select ma_gv from `giang vien` where ma_bm='$mabm')  group by `muc danh gia`");
															    $sql4=mysql_query("select `muc danh gia`,count(*) from `danh gia` a,`lop hoc phan` b where a.ma_hknk='$hknk' and `muc danh gia`='4' and a.ma_hp=b.ma_hp and a.ma_hknk=b.ma_hknk and a.stt_nhom=b.stt_nhom and a.ma_hp='$mahp' and ma_gv in (select ma_gv from `giang vien` where ma_bm='$mabm')  group by `muc danh gia`");
																   if(mysql_num_rows($sql1)==0) $muc1=0;
																   else
																   {
																   $r1=mysql_fetch_row($sql1);
																   $muc1=$r1[1];
																   }
																   if(mysql_num_rows($sql2)==0) $muc2=0;
																   else
																   {
																   $r2=mysql_fetch_row($sql2);
																   $muc2=$r2[1];
																   }
																   if(mysql_num_rows($sql3)==0) $muc3=0;
																   else
																   {
																   $r3=mysql_fetch_row($sql3);
																   $muc3=$r3[1];
																   }
																   if(mysql_num_rows($sql4)==0) $muc4=0;
																   else
																   {
																   $r4=mysql_fetch_row($sql4);
																   $muc4=$r4[1];
																   }
						   ?>
						   <tr >
						       <td  height="40" style="font-size:20px;" align="center">
							         <?php echo $mahp; ?> 
							   </td>
							   <td style="font-size:20px" align="center">
							        <?php
																				   
								          echo $tenhp;
									?>
							   </td>
							   
							   <td align="center" style="font-size:20px">
							          <?php echo $muc1; ?>
							   </td>
					
							   <td  align="center" style="font-size:20px">
							        <?php
									      $t=($muc1/($demsv*11))*100;
										  $t1=round($t,2);
										  $khl[]=$t1; 
										  echo " $t1 %  ";
										  
									?>
							   </td>
							   <td align="center" style="font-size:20px">
							          <?php echo $muc2; ?>
							   </td>
							   <td  align="center" style="font-size:20px">
							       <?php
									       
										  $t=($muc2/($demsv*11))*100;
										  $t1=round($t,2);
										  $hl[]=$t1; 
										  echo " $t1 %  ";
									?>
							   </td>
							   <td align="center" style="font-size:20px">
							          <?php echo $muc3; ?>
							   </td>
							   <td  align="center" style="font-size:20px">
							          <?php
									      
										  $t=($muc3/($demsv*11))*100;
										  $t1=round($t,2); 
										  $rhl[]=$t1;
										  echo " $t1 %  ";
									 ?>
							   </td>
							   <td align="center" style="font-size:20px">
							          <?php echo $muc4; ?>
							   </td>
							   <td  align="center" style="font-size:20px">
							          <?php
									       $t=($muc4/($demsv*11))*100;
										  $t1=round($t,2);
										  $xs[]=$t1; 
										  echo " $t1 %  ";
										   
									?>
							   </td> 
							  
								 
							     
                           </tr>
						   <?php
						      
						}//while
						 
					 
		   ?>
										  
										   </table>
				</td>
			</tr>
           
      		
          <tr><td height="30">&nbsp;</td></tr>
		  <?php }//ngoac while lon ?>
		   
		  <tr><td height="20" >&nbsp; </td></tr>
		  </table>
		 </td>
		 </tr>
</body>
</html>
